package cn.tedu;

import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;

import java.util.Scanner;

/*本类用于综合编程案例--年龄生肖*/
public class zodiac {
    public void year() {
            System.out.println("请输入你的年龄:");
            int age = new Scanner(System.in).nextInt();
            System.out.println("出生于" + (2021 - age) + "年");
//            String[] category = {"鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"};
//            int k = (2021-age)%12-4;
//            System.out.println(category[k]);
            try {
                while (true) {
                    int k = (2021 - age) % 12 - 4;
                    switch (k) {
                        case 0:
                            System.out.println("鼠年");
                            break;
                        case 1:
                            System.out.println("牛年");
                            break;
                        case 2:
                            System.out.println("虎年");
                            break;
                        case 3:
                            System.out.println("兔年");
                            break;
                        case 4:
                            System.out.println("龙年");
                            break;
                        case 5:
                            System.out.println("蛇年");
                            break;
                        case 6:
                            System.out.println("马年");
                            break;
                        case 7:
                            System.out.println("羊年");
                            break;
                        case 8:
                            System.out.println("猴年");
                            break;
                        case 9:
                            System.out.println("鸡年");
                            break;
                        case 10:
                            System.out.println("狗年");
                            break;
                        case 11:
                            System.out.println("猪年");
                            break;
                        default:
                            System.out.println("输入错误");
                            break;
                    }
                    break;
                }
            } catch (Exception e) {
                System.out.println("请正常输入");
                e.printStackTrace();
            }

    }
}
